今天繼續switch case
// hello19
package main
import (
"os/exec"
"time"
)
func main() {
// 取得系統時間
t := time.Now()
hour := t.Hour()
switch hour {
case 10:
cmd := exec.Command("notify-send", "-i",
"/home/asami/Study2014/S1407/go/hello19/golang.png",
"Golang 關心您", "總裁喝杯咖啡吧!")
cmd.Start()
case 11:
cmd := exec.Command("notify-send", "-i",
"/home/asami/Study2014/S1407/go/hello19/golang.png",
"Golang 關心您", "總裁吃午餐囉!")
cmd.Start()
default:
cmd := exec.Command("notify-send", "-i",
"/home/asami/Study2014/S1407/go/hello19/golang.png",
"Golang 關心您", "總裁記得匯奶粉錢啊!")
cmd.Start()
}
}
執行結果, 會在桌面右上角提醒總裁吃午餐.